package com.huike.web.controller.clues;

import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueRecordVo;
import com.huike.clues.service.ITbClueService;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/clues/record")
public class TbClueRecordController {
    @Autowired(required = false)
    private ITbClueService tbClueService;

    @PostMapping
    public AjaxResult addCluesRecords(@RequestBody ClueRecordVo clueRecordVo) {
        tbClueService.addCluesRecords(clueRecordVo);
        return AjaxResult.success();
    }

    /**
     * 查询线索跟进记录列表
     * <p>
     * 难度级别 C级
     *
     * @param clueId
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo getClueRecordList(String clueId) {
        System.out.println(clueId);
        List<TbClueTrackRecord> clueRecordList = tbClueService.getClueRecordList(clueId);
        TableDataInfo tableDataInfo = new TableDataInfo(clueRecordList, clueRecordList.size());
        tableDataInfo.setTotal(clueRecordList.size());
        tableDataInfo.setMsg("查询成功");
        tableDataInfo.setCode(200);
        return tableDataInfo;
    }
}

